def max_sub_array(nums) -> int:
    for i in range(1, len(nums)):
        nums[i] += max(nums[i - 1], 0)
        return max(nums)

